﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AddIn.EA.Framework;
using AddIn.EA.Architecture.CatalogService.BusinessEntity;
using AddIn.EA.Architecture.CatalogService.BusinessEntity.Enum;

namespace AddIn.EA.Architecture.CatalogService.BusinessLogic
{
    public class NamespaceXml
    {
        private RepositoryManager repository { get; set; }
        private Package service { get; set; }

        public NamespaceXml(RepositoryManager repository, Package service)
        {
            this.repository = repository;
            this.service = service;
        }

        /// <summary>
        /// Gera os XMLs com a descricao dos namespaces
        /// </summary>
        /// <returns></returns>
        public List<MemberBase> GetNamespaceXmls()
        {
            var namespaceXmls = new List<MemberBase>();

            // Classes base
            namespaceXmls.Add(new MemberNamespace
            {
                ProjectGUID = this.repository.ProjectGUID,
                Name = this.service.Element.GetFullNamespace() + ".DataContract",
                Summary = "Namespace que armazena entidades (DataContract) utilizadas como classe base para os namespaces de Request e Response. Não devem ser usadas diretamente."
            });

            // Enums
            namespaceXmls.Add(new MemberNamespace
            {
                ProjectGUID = this.repository.ProjectGUID,
                Name = this.service.Element.GetFullNamespace() + ".DataContract.Enum",
                Summary = "Namespace que armazena todos os enumeradores (Enum) utilizados no submódulo.",
                Example = new Example
                {
                    Code = new List<Code>
                    {
                        new Code { Lang = Language.cs, Source = @"ExampleCode\ExampleCS\Enum.cs" }
                    }
                }
            });

            // Classes Request
            namespaceXmls.Add(new MemberNamespace
            {
                ProjectGUID = this.repository.ProjectGUID,
                Name = this.service.Element.GetFullNamespace() + ".DataContract.Request",
                Summary = "Namespace que armazena entidades (DataContract) utilizadas nas requisições aos serviços do submódulo.",
                Example = new Example
                {
                    Code = new List<Code>
                    {
                        new Code { Lang = Language.cs, Source = @"ExampleCode\ExampleCS\Request.cs" }
                    }
                }
            });

            // Classes Response
            namespaceXmls.Add(new MemberNamespace
            {
                ProjectGUID = this.repository.ProjectGUID,
                Name = this.service.Element.GetFullNamespace() + ".DataContract.Response",
                Summary = "Namespace que armazena entidades (DataContract) retornadas pelos serviços do submódulo.",
                Example = new Example
                {
                    Code = new List<Code>
                    {
                        new Code { Lang = Language.cs, Source = @"ExampleCode\ExampleCS\Response.cs" }
                    }
                }
            });

            // Interfaces
            namespaceXmls.Add(new MemberNamespace
            {
                ProjectGUID = this.repository.ProjectGUID,
                Name = this.service.Element.GetFullNamespace() + ".ServiceContract",
                Summary = "Namespace que contém todos os serviços providos pela submódulo. Os serviços são expostos atraves de interfaces (ServiceContract) e métodos (OperationContract).",
                Example = new Example
                {
                    Code = new List<Code>
                    {
                        new Code { Lang = Language.cs, Source = @"ExampleCode\ExampleCS\ServiceContract.cs" }
                    }
                }
            });

            return namespaceXmls;
        }
    }
}
